<template>
  <div id="goods-evaluate">
    <van-nav-bar title="商品评价" left-text="返回" left-arrow @click-left="$router.go(-1)" />

    <div id="content" style="margin-top: 10px;">
      <van-list v-for="evaluate in evaluateLists" :key="evaluate.id">
        <div class="evaluation-card">
          <div class="top-bar">
            <img :src="evaluate.avatar" class="avatar" />
            <div class="nickname">
              <span class="top-bar__info__name">{{ evaluate.nickname }}</span>
              <div class="top-bar__info__star"><van-rate v-model="evaluate.rank" :size="12" color="#BDA570" void-icon="star" void-color="#eee" /></div>
            </div>
            <div class="time">
              <div>{{ evaluate.create_time }}</div>
            </div>
          </div>
          <div>
            <div class="evaluation-content">
              <p class="">{{ evaluate.content }}</p>
            </div>
          </div>
        </div>
      </van-list>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      evaluateLists: []
    };
  },
  created() {
    this.loadLists();
  },
  methods: {
    loadLists() {
      let goods_id = this.$route.query.goods_id;

      this.apiPost('/shop.goods/evaluate', { goods_id: goods_id }).then(res => {
        this.evaluateLists = res.data;
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.evaluation-card {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 0 10px;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  background-color: #fff;
}

.top-bar {
  width: 100%;
  height: 46px;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: flex;
  padding: 5px 15px;
  -moz-box-sizing: border-box;
  box-sizing: border-box;

  .avatar {
    width: 36px;
    border-radius: 100px;
  }

  .nickname {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -moz-box-flex: 1;
    flex: 1;
    color: #111;
    font-size: 12px;
    font-weight: 500;
    line-height: 14px;
    margin-left: 10px;
    position: relative;

    .top-bar__info__star {
      bottom: 0;
      font-size: 10px;
      position: absolute;
    }
  }

  .time {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -moz-box-flex: 1;
    flex: 1;
    color: #999;
    font-size: 12px;
    line-height: 14px;
    text-align: right;
  }
}

.evaluation-content {
  color: #111;
  font-size: 14px;
  line-height: 20px;
  padding: 5px 15px;
}
</style>
